//
//  AnimationsViewViewController.m
//  30303
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "AnimationsViewViewController.h"

@interface AnimationsViewViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *plane;

@end

@implementation AnimationsViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    // 方式1
    //    [UIView beginAnimations:nil context:nil];
    //    [UIView setAnimationDuration:1];
    //    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    ////    [UIView setAnimationRepeatAutoreverses:YES];
    //    [UIView setAnimationRepeatCount:NSNotFound];
    //
    //    // 中止值
    //    CGPoint center = self.plane.center;
    //    center.x += 100;
    //    center.y += 100;
    //    self.plane.center = center;
    //    
    //    [UIView commitAnimations];

    
    //方式2
    [UIView animateWithDuration:1 delay:0 usingSpringWithDamping:5 initialSpringVelocity:5 options:UIViewAnimationOptionCurveEaseInOut animations:
     ^{
     CGPoint center = self.plane.center;
        center.x += 100;
         center.y += 200;
         self.plane.center = center;
     }
          completion:^(BOOL finished) {
              
          }];
}
@end
